/*
 * Copyright (c) 2023-2025 110476592@qq.com
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 */

/**
 * @file abs_float_toolbar.h
 * @brief 截图工具 
 * @author 110476592@qq.com 
 * @note   承接Qt项目外包定制开发。长期接收C++项目实训学徒,联系QQ：110476592。
 */

 
#ifndef ABS_FLOAT_TOOLBAR_H
#define ABS_FLOAT_TOOLBAR_H

#include <QWidget>
#include <QButtonGroup>
#include <QHBoxLayout>
#include <QVBoxLayout>
#include <QRect>
#include <QToolButton>
#include <common/global.h>
#include <widgets/toolbuttonex.h>
#include <vector>

/**
 * @brief 浮动工具栏基类
 */
class AbsFloatToolBar : public QWidget
{
    Q_OBJECT
public:
    explicit AbsFloatToolBar(QWidget *parent = nullptr);

    virtual ~AbsFloatToolBar();
    /**
     * @brief 调整工具栏的位置
     * @param parentRect
     * @param selectionRect
     */
    virtual void updatePosition(const QRect & parentRect,const QRect & selectionRect) = 0;

    /**
     * @brief 初始化工具栏按钮
     */
    virtual void initButtons() = 0;

    /**
     * @brief 禁用按钮状态
     * @param disables
     * @param enable 是否启用
     */
    void enableButton(CommandType cmdId,bool enable);

protected:
    /**
     * @brief 返回窗口首选大小（即推荐的最小大小）
     * @return
     */
    QSize preferredSize();

    /**
     * @brief 创建按钮
     * @param btn
     * @param fontCode
     * @param actionType 操作类型
     */
    ToolButtonEx *addToolButton(const QString & title,
                                  int fontCode ,
                                   CommandType cmdType );



signals:
    /**
     * @brief 点击工具栏按钮
     * @param button
     */
    void onClicked(ToolButtonEx *button);

protected:

  QButtonGroup * m_buttonGroup;  ///< 按钮组
  QHBoxLayout *  m_hLayout;  ///< 水平布局
  QVBoxLayout *  m_vLayout;  ///< 垂直布局

  std::vector<ToolButtonEx*> m_buttons; ///< 所有按钮
};

#endif // ABS_FLOAT_TOOLBAR_H
